﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using SmallERP.MODEL.FoundationModel;
using SmallERP.DAL;
using System.Data;
using Smallerp.Contracts;

namespace SmallERP.Bll.PrintManage
{

    public class PaperTypeBLL
    {
        IOperateDB _OperateDb;
        public PaperTypeBLL(IOperateDB _op)
        {
            _OperateDb = _op;
        }
        /// <summary>
        ///  获得纸型列表
        /// </summary>
        /// <returns></returns>
        public List<PaperType_Info> GetPaperTypeList()
        {
            List<PaperType_Info> list = new List<PaperType_Info>();
            DataTable dt = _OperateDb.QueryDataTable("select * from PaperType");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow row = dt.Rows[i];
                PaperType_Info paperFace = new PaperType_Info();
                paperFace.PaperTypeId = Convert.ToInt32(row["PaperTypeId"]);
                paperFace.PaperTypeName = (row["PaperTypeName"]).ToString();
                list.Add(paperFace);

            }
            return list;
            
        }


        /// <summary>
        /// 获得纸型
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public PaperType_Info GetPaperType(string name)
        {
            DataTable dt = _OperateDb.QueryDataTable("select * from PaperType where PaperTypeName='" + name + "'");

            DataRow row = dt.Rows[0];
            PaperType_Info papertypeInfo = new PaperType_Info();
            papertypeInfo.PaperTypeId = Convert.ToInt32(row["PaperTypeId"]);
            papertypeInfo.PaperTypeName = (row["PaperTypeName"]).ToString();
            return papertypeInfo;
        }
    }
}
